package com.yunchi.schedule;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * @Author: Crazer
 * @Date: 2023/7/7 14:43
 * @version: 1.0.0
 * @Description: 实现项目启动执行一次定时任务
 */
@Component
public class MyApplicationRunner implements ApplicationRunner {

    private final MonitorTask monitorTask;

    @Autowired
    public MyApplicationRunner(MonitorTask monitorTask) {
        this.monitorTask = monitorTask;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        // 在 Spring Boot 启动时执行一次的逻辑
        monitorTask.monitor();
        monitorTask.monitorCDisk();
    }
}



